<#import "/layout/mainLayout.html" as mainLayout />

<#macro mainheading>

</#macro>
<#assign mainheading = mainheading in mainLayout />

<#macro maincontent>
    <section class="content">
        <div class="box-header">
            <div class="row">


                <div class="col-sm-4">
                    <input type="text" class="form-control" id="input_name" placeholder="名称...">
                </div>


                <div class="col-sm-1 pull-right">
                    <button class="btn btn-block btn-default " id ="btn_search" onclick="searchPriceTags()">查询
                    </button>
                </div>
            </div><!-- /.box-header -->
        </div>
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <div class="row">
                            <div class="col-sm-9">
                            </div>
                            <div class="col-sm-3">
                                <a class="btn btn-block btn-success" href="/page/price/pricetagadd">+
                                    添加价格标签</a>
                            </div>
                        </div>
                    </div>
                    <div class="box-body table-responsive no-padding">
                        <table class="table table-bordered table-striped dataTable">
                            <tbody>
                            <thead>
                            <tr>
                                <th>名称</th>
                                <th>人民币</th>
                                <th>零钱</th>
                                <th>观看天数</th>
                                <th>添加时间</th>
                                <th>描述</th>
                                <th style="text-align: center">操作</th>
                            </tr>
                            </thead>
                            <tbody id="bodycontent">


                            </tbody>
                        </table>
                    </div><!-- /.box-body -->
                    <div id="pagecontent" class="pagination"></div>
                </div><!-- /.box -->
            </div>
        </div>
    </section>

</#macro>
<#assign maincontent = maincontent in mainLayout />

<#macro mainfooter>
    <!--layoutmain footer...-->
    <!--<br />-->
    <script type="text/javascript">
        var price_data = {
        };

        function searchPriceTags() {
            price_data = {
                name:$('#input_name').val(),
                pno: 1,
                pagesize: 10,
                allcount:-1
            };
            LoadPriceTagList();
        }
        //加载列表
        searchPriceTags();
        function LoadPriceTagList() {
            $('#pagecontent').html('');
            $.ajax({
                    url: '/api/price/pricelist',
                    data: price_data,
                    dataType: 'json',
                    success: function (data) {
                        if (mortise_layout.ValidataResult(data)) {
                            if (data.result) {
                                price_data.allcount = data.result.count;
                                var html = '';
                                $.each(data.result.list, function (index, item) {
                                    html += getHtml(item);
                                })
                                $('#bodycontent').html(html);
                                ShowPage('pagecontent', price_data, function (pno) {
                                    price_data.pno = pno;
                                    LoadPriceTagList();
                                });
                            }
                            else {
                                alert('返回数据错误！');
                            }
                        }
                        else {
                            alert('请求数据失败！');
                        }
                    }
                }
            );
        }
        function  getHtml(dataObject) {

            return ' <tr>'+
                '<td>'+dataObject.fName+'</td>'+
                '<td>'+dataObject.fMoney+'</td>'+
                '<td>'+dataObject.fCoin+'</td>'+
                '<td>'+dataObject.fOffday+'</td>'+
                '<td>'+dataObject.fIntime+'</td>'+
                '<td>'+dataObject.fDesc+'</td>'+
                '<td>' +
                '<a style="cursor: pointer" href="/page/price/pricetagupdate?fid='+dataObject.fId+'" >修改</a></td>'+
                '</tr>';
        }

    </script>
</#macro>
<#assign mainfooter = mainfooter in mainLayout />
<@mainLayout.page title="用户管理"/>